Skip to content

Keep posting campaign when frontmatter has no campaign keys#384

Merged
ohakutsu merged 1 commit into
mainfrom
keep-posting-campaign-without-frontmatter-keys
Jul 13, 2026
Merged

Keep posting campaign when frontmatter has no campaign keys#384
ohakutsu merged 1 commit into
mainfrom
keep-posting-campaign-without-frontmatter-keys

Conversation

@yuta0709

@yuta0709 yuta0709 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What

  • frontmatter に posting_campaign_uuid キーがない記事ファイルを publish しても、記事投稿キャンペーンの紐付けが解除されないようにした

How

  • frontmatter のキャンペーンキーを3通りに区別するようにした
    • キーなし: キャンペーンの紐付けを変更しない(APIリクエストからキーを省略する)
    • posting_campaign_uuid: null: 紐付けを解除する
    • UUIDを指定: キャンペーンに紐付ける
  • キーがないファイルはキャンペーン項目を差分判定(equals)の対象から除外し、frontmatterに該当の項目がない既存ファイルが一律「変更あり」扱いにならないようにした

Why

  • キーがない場合を null に変換してAPIに送信しており、APIは null を「紐付け解除」と解釈するため、v1.9.0 より前から管理しているファイルの publish でキャンペーンが外れてしまっていた

Refs

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@yuta0709 yuta0709 self-assigned this Jul 10, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the postingCampaignUuid and agreedPostingCampaignTerm fields across the codebase to support undefined values, allowing these fields to be optional. The changes include updating type definitions, modifying validation logic to handle undefined inputs, adjusting how these fields are serialized and compared, and adding unit tests to verify the new behavior. I have no feedback to provide as there were no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@yuta0709
yuta0709 requested a review from ohakutsu July 10, 2026 09:44
@ohakutsu
ohakutsu requested review from tomoasleep and removed request for ohakutsu July 13, 2026 01:18
});
});

it("returns null for an explicit null", () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

posting_campaign_uuid がない場合に undefined にするテストも欲しいです

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomoasleep
こちらのテストは describe("when posting campaign keys are absent in frontmatter") 内の it("keeps them undefined") で追加しています(キーなしのfrontmatterを読み込んで postingCampaignUuid / agreedPostingCampaignTermundefined になることを確認しています)。

describe("when posting campaign keys are absent in frontmatter", () => {
it("keeps them undefined", () => {
const instance = new FileSystemRepo({ dataRootDir: "data_root_dir" });
const basename = "abc";
const mockFs = fs as jest.Mocked<typeof fs>;
mockFs.readdir.mockResolvedValueOnce([`${basename}.md`] as any[]);
mockFs.readFile.mockResolvedValue(`---
id: this_is_id
tags: []
---`);
return instance.loadItemByBasename(basename).then((item) => {
expect(item?.postingCampaignUuid).toBeUndefined();
expect(item?.agreedPostingCampaignTerm).toBeUndefined();
});
});

もし意図されていたのが別のケースでしたら補足いただけると助かります!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

すみません、そっちのテストを見落としてました 🙏 であれば問題ないと思います。

@ohakutsu
ohakutsu merged commit 1c18282 into main Jul 13, 2026
6 checks passed
@ohakutsu
ohakutsu deleted the keep-posting-campaign-without-frontmatter-keys branch July 13, 2026 06:16
@ohakutsu ohakutsu mentioned this pull request Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants